package demo3;

public class Test4 {
    public static void main1(String[] args) {
       Integer[] arr = {1,33 , 42 , 32} ;
       Alg<Integer> alg = new Alg<>();
        System.out.println(alg.arrayMax(arr));
    }

    public static void main(String[] args) {
        Alg2 alg2 = new Alg2() ;
        Integer[] arr = {1,33 , 42 , 32} ;
        Integer ret =   alg2.<Integer>arrayMax(arr) ;
    }

}
class Alg2{
    public static <T extends Comparable<T>> T arrayMax(T[] arr){
        T max = arr[0] ;
        for(int i = 1 ; i < arr.length ;i++){
            if(arr[i].compareTo(max) > 0){
                max = arr[i] ;
            }
        }
        return max ;
    }


}

//class A<T extends Number>{
//
//    Object[] array = new Object[10] ;
//
//
//}


class Alg <T extends Comparable<T>>{

    public T arrayMax(T[] arr){
        T max = arr[0] ;
        for(int i = 1 ; i < arr.length ;i++){
           if(arr[i].compareTo(max) > 0){
              max = arr[i] ;
           }
        }
        return max ;
    }

}
